{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取excel文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "excel_file = r'/home/excel/python_program/data/lab1/SH#600519.xlsx'\n",
    "\n",
    "data = pd.read_excel(excel_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "test = pd.read_excel(io=excel_file, \n",
    "                     header=1, \n",
    "                     skiprows=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/home/excel/python_program/data/lab1/SH#600519.xlsx'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "excel_file"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 新建一个 DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "df = pd.DataFrame(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "dfs = pd.DataFrame(test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2001-08-27</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-28</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-29</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-30</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-31</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4540</th>\n",
       "      <td>2020-09-01</td>\n",
       "      <td>1792.00</td>\n",
       "      <td>1802.00</td>\n",
       "      <td>1775.01</td>\n",
       "      <td>1801.98</td>\n",
       "      <td>3163992</td>\n",
       "      <td>5661594112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4541</th>\n",
       "      <td>2020-09-02</td>\n",
       "      <td>1825.00</td>\n",
       "      <td>1828.00</td>\n",
       "      <td>1770.00</td>\n",
       "      <td>1795.00</td>\n",
       "      <td>3200929</td>\n",
       "      <td>5746352128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4542</th>\n",
       "      <td>2020-09-03</td>\n",
       "      <td>1795.00</td>\n",
       "      <td>1812.00</td>\n",
       "      <td>1779.70</td>\n",
       "      <td>1793.00</td>\n",
       "      <td>3043735</td>\n",
       "      <td>5471333888</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4543</th>\n",
       "      <td>2020-09-04</td>\n",
       "      <td>1766.00</td>\n",
       "      <td>1776.99</td>\n",
       "      <td>1746.00</td>\n",
       "      <td>1770.00</td>\n",
       "      <td>3085796</td>\n",
       "      <td>5433479168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4544</th>\n",
       "      <td>2020-09-07</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>1777.99</td>\n",
       "      <td>1703.97</td>\n",
       "      <td>1723.50</td>\n",
       "      <td>3111202</td>\n",
       "      <td>5446354432</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4545 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             日期       开盘       最高       最低       收盘       成交量         成交额\n",
       "0    2001-08-27   -70.43   -69.78   -70.76   -70.23  40631800  1410347136\n",
       "1    2001-08-28   -70.34   -69.94   -70.41   -69.96  12964700   463463136\n",
       "2    2001-08-29   -69.94   -69.94   -70.12   -70.06   5325200   194689616\n",
       "3    2001-08-30   -70.08   -69.84   -70.14   -69.92   4801300   177558560\n",
       "4    2001-08-31   -69.91   -69.81   -69.98   -69.93   2323100    86231000\n",
       "...         ...      ...      ...      ...      ...       ...         ...\n",
       "4540 2020-09-01  1792.00  1802.00  1775.01  1801.98   3163992  5661594112\n",
       "4541 2020-09-02  1825.00  1828.00  1770.00  1795.00   3200929  5746352128\n",
       "4542 2020-09-03  1795.00  1812.00  1779.70  1793.00   3043735  5471333888\n",
       "4543 2020-09-04  1766.00  1776.99  1746.00  1770.00   3085796  5433479168\n",
       "4544 2020-09-07  1760.00  1777.99  1703.97  1723.50   3111202  5446354432\n",
       "\n",
       "[4545 rows x 7 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>开盘</th>\n",
       "      <td>1.225959e+05</td>\n",
       "      <td>1.240962e+05</td>\n",
       "      <td>1.213285e+05</td>\n",
       "      <td>1.228183e+05</td>\n",
       "      <td>2.466266e+08</td>\n",
       "      <td>4.496411e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>最高</th>\n",
       "      <td>1.240962e+05</td>\n",
       "      <td>1.256429e+05</td>\n",
       "      <td>1.228243e+05</td>\n",
       "      <td>1.243512e+05</td>\n",
       "      <td>2.525473e+08</td>\n",
       "      <td>4.569283e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>最低</th>\n",
       "      <td>1.213285e+05</td>\n",
       "      <td>1.228243e+05</td>\n",
       "      <td>1.200954e+05</td>\n",
       "      <td>1.215728e+05</td>\n",
       "      <td>2.420823e+08</td>\n",
       "      <td>4.438254e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>收盘</th>\n",
       "      <td>1.228183e+05</td>\n",
       "      <td>1.243512e+05</td>\n",
       "      <td>1.215728e+05</td>\n",
       "      <td>1.230895e+05</td>\n",
       "      <td>2.477110e+08</td>\n",
       "      <td>4.508591e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>成交量</th>\n",
       "      <td>2.466266e+08</td>\n",
       "      <td>2.525473e+08</td>\n",
       "      <td>2.420823e+08</td>\n",
       "      <td>2.477110e+08</td>\n",
       "      <td>5.912810e+12</td>\n",
       "      <td>2.138142e+15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>成交额</th>\n",
       "      <td>4.496411e+11</td>\n",
       "      <td>4.569283e+11</td>\n",
       "      <td>4.438254e+11</td>\n",
       "      <td>4.508591e+11</td>\n",
       "      <td>2.138142e+15</td>\n",
       "      <td>2.314621e+18</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               开盘            最高            最低            收盘           成交量  \\\n",
       "开盘   1.225959e+05  1.240962e+05  1.213285e+05  1.228183e+05  2.466266e+08   \n",
       "最高   1.240962e+05  1.256429e+05  1.228243e+05  1.243512e+05  2.525473e+08   \n",
       "最低   1.213285e+05  1.228243e+05  1.200954e+05  1.215728e+05  2.420823e+08   \n",
       "收盘   1.228183e+05  1.243512e+05  1.215728e+05  1.230895e+05  2.477110e+08   \n",
       "成交量  2.466266e+08  2.525473e+08  2.420823e+08  2.477110e+08  5.912810e+12   \n",
       "成交额  4.496411e+11  4.569283e+11  4.438254e+11  4.508591e+11  2.138142e+15   \n",
       "\n",
       "              成交额  \n",
       "开盘   4.496411e+11  \n",
       "最高   4.569283e+11  \n",
       "最低   4.438254e+11  \n",
       "收盘   4.508591e+11  \n",
       "成交量  2.138142e+15  \n",
       "成交额  2.314621e+18  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfs.cov()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>开盘</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.999888</td>\n",
       "      <td>0.999912</td>\n",
       "      <td>0.999803</td>\n",
       "      <td>0.289671</td>\n",
       "      <td>0.844089</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>最高</th>\n",
       "      <td>0.999888</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.999890</td>\n",
       "      <td>0.999933</td>\n",
       "      <td>0.293006</td>\n",
       "      <td>0.847304</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>最低</th>\n",
       "      <td>0.999912</td>\n",
       "      <td>0.999890</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.999914</td>\n",
       "      <td>0.287278</td>\n",
       "      <td>0.841800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>收盘</th>\n",
       "      <td>0.999803</td>\n",
       "      <td>0.999933</td>\n",
       "      <td>0.999914</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.290361</td>\n",
       "      <td>0.844676</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>成交量</th>\n",
       "      <td>0.289671</td>\n",
       "      <td>0.293006</td>\n",
       "      <td>0.287278</td>\n",
       "      <td>0.290361</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.577962</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>成交额</th>\n",
       "      <td>0.844089</td>\n",
       "      <td>0.847304</td>\n",
       "      <td>0.841800</td>\n",
       "      <td>0.844676</td>\n",
       "      <td>0.577962</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           开盘        最高        最低        收盘       成交量       成交额\n",
       "开盘   1.000000  0.999888  0.999912  0.999803  0.289671  0.844089\n",
       "最高   0.999888  1.000000  0.999890  0.999933  0.293006  0.847304\n",
       "最低   0.999912  0.999890  1.000000  0.999914  0.287278  0.841800\n",
       "收盘   0.999803  0.999933  0.999914  1.000000  0.290361  0.844676\n",
       "成交量  0.289671  0.293006  0.287278  0.290361  1.000000  0.577962\n",
       "成交额  0.844089  0.847304  0.841800  0.844676  0.577962  1.000000"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfs.corr()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2001-08-27</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-28</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-29</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-30</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-31</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4540</th>\n",
       "      <td>2020-09-01</td>\n",
       "      <td>1792.00</td>\n",
       "      <td>1802.00</td>\n",
       "      <td>1775.01</td>\n",
       "      <td>1801.98</td>\n",
       "      <td>3163992</td>\n",
       "      <td>5661594112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4541</th>\n",
       "      <td>2020-09-02</td>\n",
       "      <td>1825.00</td>\n",
       "      <td>1828.00</td>\n",
       "      <td>1770.00</td>\n",
       "      <td>1795.00</td>\n",
       "      <td>3200929</td>\n",
       "      <td>5746352128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4542</th>\n",
       "      <td>2020-09-03</td>\n",
       "      <td>1795.00</td>\n",
       "      <td>1812.00</td>\n",
       "      <td>1779.70</td>\n",
       "      <td>1793.00</td>\n",
       "      <td>3043735</td>\n",
       "      <td>5471333888</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4543</th>\n",
       "      <td>2020-09-04</td>\n",
       "      <td>1766.00</td>\n",
       "      <td>1776.99</td>\n",
       "      <td>1746.00</td>\n",
       "      <td>1770.00</td>\n",
       "      <td>3085796</td>\n",
       "      <td>5433479168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4544</th>\n",
       "      <td>2020-09-07</td>\n",
       "      <td>1760.00</td>\n",
       "      <td>1777.99</td>\n",
       "      <td>1703.97</td>\n",
       "      <td>1723.50</td>\n",
       "      <td>3111202</td>\n",
       "      <td>5446354432</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4545 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             日期       开盘       最高       最低       收盘       成交量         成交额\n",
       "0    2001-08-27   -70.43   -69.78   -70.76   -70.23  40631800  1410347136\n",
       "1    2001-08-28   -70.34   -69.94   -70.41   -69.96  12964700   463463136\n",
       "2    2001-08-29   -69.94   -69.94   -70.12   -70.06   5325200   194689616\n",
       "3    2001-08-30   -70.08   -69.84   -70.14   -69.92   4801300   177558560\n",
       "4    2001-08-31   -69.91   -69.81   -69.98   -69.93   2323100    86231000\n",
       "...         ...      ...      ...      ...      ...       ...         ...\n",
       "4540 2020-09-01  1792.00  1802.00  1775.01  1801.98   3163992  5661594112\n",
       "4541 2020-09-02  1825.00  1828.00  1770.00  1795.00   3200929  5746352128\n",
       "4542 2020-09-03  1795.00  1812.00  1779.70  1793.00   3043735  5471333888\n",
       "4543 2020-09-04  1766.00  1776.99  1746.00  1770.00   3085796  5433479168\n",
       "4544 2020-09-07  1760.00  1777.99  1703.97  1723.50   3111202  5446354432\n",
       "\n",
       "[4545 rows x 7 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 获取dataframe的列标题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "head = df.columns.values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['日期', '开盘', '最高', '最低', '收盘', '成交量', '成交额']"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "原列名\n",
    "'''\n",
    "head"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "'''\n",
    "修改列名：\n",
    "    df.rename(columns={'原列名'：'新列名'},inplace=True)\n",
    "'''\n",
    "for i in range (len(head)):\n",
    "    df.rename(columns={head[i]:df.iloc[0,i]},inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''\n",
    "修改后的列名\n",
    "'''\n",
    "head=df.columns.values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['日期', '开盘', '最高', '最低', '收盘', '成交量', '成交额']"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "head"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4541</th>\n",
       "      <td>2020-09-01 00:00:00</td>\n",
       "      <td>1792</td>\n",
       "      <td>1802</td>\n",
       "      <td>1775.01</td>\n",
       "      <td>1801.98</td>\n",
       "      <td>3163992</td>\n",
       "      <td>5661594112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4542</th>\n",
       "      <td>2020-09-02 00:00:00</td>\n",
       "      <td>1825</td>\n",
       "      <td>1828</td>\n",
       "      <td>1770</td>\n",
       "      <td>1795</td>\n",
       "      <td>3200929</td>\n",
       "      <td>5746352128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4543</th>\n",
       "      <td>2020-09-03 00:00:00</td>\n",
       "      <td>1795</td>\n",
       "      <td>1812</td>\n",
       "      <td>1779.7</td>\n",
       "      <td>1793</td>\n",
       "      <td>3043735</td>\n",
       "      <td>5471333888</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4544</th>\n",
       "      <td>2020-09-04 00:00:00</td>\n",
       "      <td>1766</td>\n",
       "      <td>1776.99</td>\n",
       "      <td>1746</td>\n",
       "      <td>1770</td>\n",
       "      <td>3085796</td>\n",
       "      <td>5433479168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4545</th>\n",
       "      <td>2020-09-07 00:00:00</td>\n",
       "      <td>1760</td>\n",
       "      <td>1777.99</td>\n",
       "      <td>1703.97</td>\n",
       "      <td>1723.5</td>\n",
       "      <td>3111202</td>\n",
       "      <td>5446354432</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4545 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘       最高       最低       收盘       成交量  \\\n",
       "1     2001-08-27 00:00:00 -70.43   -69.78   -70.76   -70.23  40631800   \n",
       "2     2001-08-28 00:00:00 -70.34   -69.94   -70.41   -69.96  12964700   \n",
       "3     2001-08-29 00:00:00 -69.94   -69.94   -70.12   -70.06   5325200   \n",
       "4     2001-08-30 00:00:00 -70.08   -69.84   -70.14   -69.92   4801300   \n",
       "5     2001-08-31 00:00:00 -69.91   -69.81   -69.98   -69.93   2323100   \n",
       "...                   ...    ...      ...      ...      ...       ...   \n",
       "4541  2020-09-01 00:00:00   1792     1802  1775.01  1801.98   3163992   \n",
       "4542  2020-09-02 00:00:00   1825     1828     1770     1795   3200929   \n",
       "4543  2020-09-03 00:00:00   1795     1812   1779.7     1793   3043735   \n",
       "4544  2020-09-04 00:00:00   1766  1776.99     1746     1770   3085796   \n",
       "4545  2020-09-07 00:00:00   1760  1777.99  1703.97   1723.5   3111202   \n",
       "\n",
       "             成交额  \n",
       "1     1410347136  \n",
       "2      463463136  \n",
       "3      194689616  \n",
       "4      177558560  \n",
       "5       86231000  \n",
       "...          ...  \n",
       "4541  5661594112  \n",
       "4542  5746352128  \n",
       "4543  5471333888  \n",
       "4544  5433479168  \n",
       "4545  5446354432  \n",
       "\n",
       "[4545 rows x 7 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.drop(0,axis=0,inplace=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>2007-01-15 00:00:00</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>0.27</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>-1.51</td>\n",
       "      <td>3067052</td>\n",
       "      <td>305993920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1239</th>\n",
       "      <td>2007-01-17 00:00:00</td>\n",
       "      <td>-3.03</td>\n",
       "      <td>1.02</td>\n",
       "      <td>-4.21</td>\n",
       "      <td>-2.63</td>\n",
       "      <td>2591604</td>\n",
       "      <td>257353984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期    开盘     最高    最低    收盘      成交量        成交额\n",
       "1237  2007-01-15 00:00:00 -3.44   0.27 -3.44 -1.51  3067052  305993920\n",
       "1239  2007-01-17 00:00:00 -3.03   1.02 -4.21 -2.63  2591604  257353984\n",
       "1240  2007-01-18 00:00:00 -2.72   2.89 -3.47  2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00  2.69    7.7  2.69  5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00  6.36  10.79  6.28  8.69  2552122  290839232"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df[head[2]]>0),[head[0],head[1],head[2],head[3],head[4],head[5],head[6]]].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>2007-01-15 00:00:00</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>0.27</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>-1.51</td>\n",
       "      <td>3067052</td>\n",
       "      <td>305993920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1239</th>\n",
       "      <td>2007-01-17 00:00:00</td>\n",
       "      <td>-3.03</td>\n",
       "      <td>1.02</td>\n",
       "      <td>-4.21</td>\n",
       "      <td>-2.63</td>\n",
       "      <td>2591604</td>\n",
       "      <td>257353984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期    开盘     最高    最低    收盘      成交量        成交额\n",
       "1237  2007-01-15 00:00:00 -3.44   0.27 -3.44 -1.51  3067052  305993920\n",
       "1239  2007-01-17 00:00:00 -3.03   1.02 -4.21 -2.63  2591604  257353984\n",
       "1240  2007-01-18 00:00:00 -2.72   2.89 -3.47  2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00  2.69    7.7  2.69  5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00  6.36  10.79  6.28  8.69  2552122  290839232"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df[head[2]]>0),head].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1237</th>\n",
       "      <td>2007-01-15 00:00:00</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>0.27</td>\n",
       "      <td>-3.44</td>\n",
       "      <td>-1.51</td>\n",
       "      <td>3067052</td>\n",
       "      <td>305993920</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1239</th>\n",
       "      <td>2007-01-17 00:00:00</td>\n",
       "      <td>-3.03</td>\n",
       "      <td>1.02</td>\n",
       "      <td>-4.21</td>\n",
       "      <td>-2.63</td>\n",
       "      <td>2591604</td>\n",
       "      <td>257353984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘     最高     最低     收盘      成交量        成交额\n",
       "1237  2007-01-15 00:00:00  -3.44   0.27  -3.44  -1.51  3067052  305993920\n",
       "1239  2007-01-17 00:00:00  -3.03   1.02  -4.21  -2.63  2591604  257353984\n",
       "1240  2007-01-18 00:00:00  -2.72   2.89  -3.47   2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00   2.69    7.7   2.69   5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00   6.36  10.79   6.28   8.69  2552122  290839232"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "excel_file = r'/home/excel/python_program/data/SH#600519.xlsx'\n",
    "\n",
    "data = pd.read_excel(excel_file)\n",
    "\n",
    "df = pd.DataFrame(data)\n",
    "\n",
    "'''\n",
    "原列名\n",
    "'''\n",
    "head = df.columns.values.tolist()\n",
    "\n",
    "'''\n",
    "修改列名：\n",
    "    df.rename(columns={'原列名'：'新列名'},inplace=True)\n",
    "'''\n",
    "for i in range (len(head)):\n",
    "    df.rename(columns={head[i]:df.iloc[0,i]},inplace=True)\n",
    "\n",
    "'''\n",
    "修改后的列名\n",
    "'''\n",
    "head=df.columns.values.tolist()\n",
    "\n",
    "'''\n",
    "删除第一行\n",
    "'''\n",
    "df = df.drop(0,axis=0,inplace=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### i. 输入日期"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "date = input()\n",
    "dates = pd.to_datetime(date)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1238</th>\n",
       "      <td>2007-01-16 00:00:00</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>-0.63</td>\n",
       "      <td>-4.01</td>\n",
       "      <td>-2.93</td>\n",
       "      <td>3503970</td>\n",
       "      <td>344077696</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期     开盘     最高     最低     收盘      成交量        成交额\n",
       "1238  2007-01-16 00:00:00   -1.7  -0.63  -4.01  -2.93  3503970  344077696"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\n",
    "    (df[head[0]]==dates),\n",
    "     [head[0],head[1],head[2],\n",
    "      head[3],head[4],head[5],\n",
    "      head[6]\n",
    "     ]\n",
    "    ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### ii. 收盘价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "flag=(int)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1240</th>\n",
       "      <td>2007-01-18 00:00:00</td>\n",
       "      <td>-2.72</td>\n",
       "      <td>2.89</td>\n",
       "      <td>-3.47</td>\n",
       "      <td>2.69</td>\n",
       "      <td>3064535</td>\n",
       "      <td>315103136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1241</th>\n",
       "      <td>2007-01-19 00:00:00</td>\n",
       "      <td>2.69</td>\n",
       "      <td>7.7</td>\n",
       "      <td>2.69</td>\n",
       "      <td>5.79</td>\n",
       "      <td>2225551</td>\n",
       "      <td>243504208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1242</th>\n",
       "      <td>2007-01-22 00:00:00</td>\n",
       "      <td>6.36</td>\n",
       "      <td>10.79</td>\n",
       "      <td>6.28</td>\n",
       "      <td>8.69</td>\n",
       "      <td>2552122</td>\n",
       "      <td>290839232</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1243</th>\n",
       "      <td>2007-01-23 00:00:00</td>\n",
       "      <td>9.14</td>\n",
       "      <td>9.89</td>\n",
       "      <td>1.85</td>\n",
       "      <td>2.74</td>\n",
       "      <td>4178280</td>\n",
       "      <td>450098208</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1244</th>\n",
       "      <td>2007-01-24 00:00:00</td>\n",
       "      <td>2.9</td>\n",
       "      <td>8.54</td>\n",
       "      <td>2.9</td>\n",
       "      <td>6.12</td>\n",
       "      <td>1940422</td>\n",
       "      <td>212553648</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       日期    开盘     最高    最低    收盘      成交量        成交额\n",
       "1240  2007-01-18 00:00:00 -2.72   2.89 -3.47  2.69  3064535  315103136\n",
       "1241  2007-01-19 00:00:00  2.69    7.7  2.69  5.79  2225551  243504208\n",
       "1242  2007-01-22 00:00:00  6.36  10.79  6.28  8.69  2552122  290839232\n",
       "1243  2007-01-23 00:00:00  9.14   9.89  1.85  2.74  4178280  450098208\n",
       "1244  2007-01-24 00:00:00   2.9   8.54   2.9  6.12  1940422  212553648"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\n",
    "        (df[head[4]]>flag),\n",
    "       head\n",
    "      ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### iii. 波动"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.1\n"
     ]
    }
   ],
   "source": [
    "wave = (float)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期     开盘     最高     最低     收盘       成交量         成交额\n",
       "1  2001-08-27 00:00:00 -70.43 -69.78 -70.76 -70.23  40631800  1410347136\n",
       "2  2001-08-28 00:00:00 -70.34 -69.94 -70.41 -69.96  12964700   463463136\n",
       "3  2001-08-29 00:00:00 -69.94 -69.94 -70.12 -70.06   5325200   194689616\n",
       "4  2001-08-30 00:00:00 -70.08 -69.84 -70.14 -69.92   4801300   177558560\n",
       "5  2001-08-31 00:00:00 -69.91 -69.81 -69.98 -69.93   2323100    86231000"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[ \n",
    "      ( df[head[2]] > (wave+df[head[3]]) ),\n",
    "        head\n",
    "      ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### iv. 成交量高于输入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99999\n"
     ]
    }
   ],
   "source": [
    "turnover = (int)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期     开盘     最高     最低     收盘       成交量         成交额\n",
       "1  2001-08-27 00:00:00 -70.43 -69.78 -70.76 -70.23  40631800  1410347136\n",
       "2  2001-08-28 00:00:00 -70.34 -69.94 -70.41 -69.96  12964700   463463136\n",
       "3  2001-08-29 00:00:00 -69.94 -69.94 -70.12 -70.06   5325200   194689616\n",
       "4  2001-08-30 00:00:00 -70.08 -69.84 -70.14 -69.92   4801300   177558560\n",
       "5  2001-08-31 00:00:00 -69.91 -69.81 -69.98 -69.93   2323100    86231000"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[\n",
    "      (df[head[5]]>turnover),\n",
    "       head\n",
    "      ].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### v. 成交额"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9026819\n"
     ]
    }
   ],
   "source": [
    "sums = (int)(input())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>开盘</th>\n",
       "      <th>最高</th>\n",
       "      <th>最低</th>\n",
       "      <th>收盘</th>\n",
       "      <th>成交量</th>\n",
       "      <th>成交额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2001-08-27 00:00:00</td>\n",
       "      <td>-70.43</td>\n",
       "      <td>-69.78</td>\n",
       "      <td>-70.76</td>\n",
       "      <td>-70.23</td>\n",
       "      <td>40631800</td>\n",
       "      <td>1410347136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-08-28 00:00:00</td>\n",
       "      <td>-70.34</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.41</td>\n",
       "      <td>-69.96</td>\n",
       "      <td>12964700</td>\n",
       "      <td>463463136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2001-08-29 00:00:00</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-69.94</td>\n",
       "      <td>-70.12</td>\n",
       "      <td>-70.06</td>\n",
       "      <td>5325200</td>\n",
       "      <td>194689616</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2001-08-30 00:00:00</td>\n",
       "      <td>-70.08</td>\n",
       "      <td>-69.84</td>\n",
       "      <td>-70.14</td>\n",
       "      <td>-69.92</td>\n",
       "      <td>4801300</td>\n",
       "      <td>177558560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2001-08-31 00:00:00</td>\n",
       "      <td>-69.91</td>\n",
       "      <td>-69.81</td>\n",
       "      <td>-69.98</td>\n",
       "      <td>-69.93</td>\n",
       "      <td>2323100</td>\n",
       "      <td>86231000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    日期     开盘     最高     最低     收盘       成交量         成交额\n",
       "1  2001-08-27 00:00:00 -70.43 -69.78 -70.76 -70.23  40631800  1410347136\n",
       "2  2001-08-28 00:00:00 -70.34 -69.94 -70.41 -69.96  12964700   463463136\n",
       "3  2001-08-29 00:00:00 -69.94 -69.94 -70.12 -70.06   5325200   194689616\n",
       "4  2001-08-30 00:00:00 -70.08 -69.84 -70.14 -69.92   4801300   177558560\n",
       "5  2001-08-31 00:00:00 -69.91 -69.81 -69.98 -69.93   2323100    86231000"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[(df[head[6]]>sums),\n",
    "       [head[0],head[1],head[2],\n",
    "        head[3],head[4],head[5],head[6]]\n",
    "      ].head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
